-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[naga const-eval] LiteralVector and some demo builtins #8223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
eb56240
to
e948b68
Compare
This comment was marked as resolved.
This comment was marked as resolved.
a3e2ac1
to
c5081a4
Compare
Co-authored-by: SelkoSays <[email protected]> Signed-off-by: sagudev <[email protected]>
…using LiteralVector Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
let (a, ty) = self.extract_vec_with_size::<3>(a)?; | ||
let (b, _) = self.extract_vec_with_size::<3>(b)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: IMO it'd have been better to have this refactor separated for the purpose of review, but 🤷🏻♂️ it's not too hard to follow.
crate::MathFunction::Normalize => { | ||
// https://www.w3.org/TR/WGSL/#normalize-builtin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review TODO for myself: figure out what the "zero vector" domain exception listed in the standard is, and see if we need to validate it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relevant spec parts https://www.w3.org/TR/WGSL/#normalize-builtin:
The domain is all vectors except the zero vector.
and
When evaluated outside its domain, the default exception handling rules of IEEE-754 require an implementation to generate an exception and yield a NaN value. In contrast, WGSL does not mandate floating point exceptions, and may instead yield an indeterminate value. See § 15.7.2 Differences from IEEE-754.
So we can do anything we want, current code will return NaN.
Just wanted to acknowledge that I'm taking a long time to finish this review. I haven't had bandwidth to spare, with some Mozilla tasks overriding my other priorities. I'm hoping to get to this early next week! ❤️💦 |
Connections
Continuation of #6213.
Implements some functions in const #4507.
Description
Existing macros work for component-wise cases where return type is equal to input type. But it's hard to generalize macros further. So I present
LiteralVector
:that abstracts away at least vector obtaining logic. This makes it easier to implement some builtins that needs access to all components like
dot
,length
,distance
(folds LiteralVector to Literal) andnormalize
(maps LiteralVector).Testing
There are some snapshot tests.
Squash or Rebase?
Reviewable per commit.
Squash
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.